package com.organize.plugin;

import com.autumn.zero.authorization.plugins.AbstractResourcesModulePlugin;
import com.autumn.zero.authorization.plugins.data.ResourcesModuleData;
import com.organize.configure.OrganizeComponentProperties;
import com.organize.res.OrganizeResUtils;

import java.util.List;

/**
 * 资源菜单插件
 * <p>
 * </p>
 *
 * @description TODO
 * @author: 老码农
 * @create: 2020-10-17 16:51
 **/
public class OrganizeResourcesModulePluginImpl extends AbstractResourcesModulePlugin {

    private final OrganizeComponentProperties properties;

    public OrganizeResourcesModulePluginImpl(OrganizeComponentProperties properties) {
        this.properties = properties;
    }

    @Override
    public List<ResourcesModuleData> createModules() {
        List<ResourcesModuleData> items = OrganizeResUtils.readOrgResourcesModules();
        if (items.size() > 0) {
            ResourcesModuleData item = items.get(0);
            item.setName(this.properties.getMenu().getRootMenuName());
            item.setCustomName(item.getName());
        }
        return items;
    }

    @Override
    public String getName() {
        return "OrganizeResourcesModulePlugin";
    }

    @Override
    public String getDescribe() {
        return "Organize 资源与菜单";
    }
}
